import java.util.Scanner;
class Solution {
    public static void main (String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long[] arr = new long[n];
        long[] dp = new long[n + 1];
        for(int i = 0;i < n;i ++) {
            arr[i] = scan.nextInt();
            dp[i+1] = dp[i] + arr[i];
        }
        long sum = 0;
        for(int i = 0;i < n-1;i ++) {
            sum += arr[i] * (dp[n] - dp[i+1]);
        }
        System.out.println(sum);
    }
}